/*
https://leetcode.cn/problems/majority-element/
LC169. 多数元素
*/
class Solution {
public:
    int majorityElement(vector<int>& nums) {
        int a,b=0;
        for(int i=0;i<nums.size();++i){
            if(b==0){
                a=nums[i];
                ++b;
                continue;
            }
            if(nums[i]!=a) --b;
            else ++b;
        }
        return a;
    }
};